#include "IrrEngine.h"
#include <assert.h>

IrrEngine::IrrEngine()
{
}
bool IrrEngine::Init()
{
	return Init(EDT_DIRECT3D9, 640, 480, 16, false, false, false, 0);
}
bool IrrEngine::Init(E_DRIVER_TYPE deviceType, int x, int y, int bits, bool fullscreen,bool stencilbuffer,bool vsync,IEventReceiver* receiver)
{

	//create the device
	m_pDevice = irr::createDevice(deviceType, dimension2d<u32>(x,y),bits, fullscreen, stencilbuffer, vsync, receiver);
	if (!m_pDevice)
	{
		assert("error creating device");
		return false;
	}

	//set pointers
	m_pDriver = m_pDevice->getVideoDriver();
	m_pSmgr = m_pDevice->getSceneManager();
	m_pGuiEnv = m_pDevice->getGUIEnvironment();

	//caption the window
	m_pDevice->setWindowCaption(L"Irrlicht Engine");
	return true;
}
void IrrEngine::Draw()
{
	m_pDriver->beginScene(true, true, irr::video::SColor(255,100,101,140));

	m_pSmgr->drawAll();
	m_pGuiEnv->drawAll();

	m_pDriver->endScene();
}

void IrrEngine::Cleanup()
{
	m_pDevice->drop();
}